import paramiko
import time

username='jngd'
password='Huawei@123'

f1=open('ip20220314.txt')
f2=open('iplist20220314.txt')
#print(f1.readlines())
for ip,loop_ip in zip(f1.readlines(),f2.readlines()):
	print(ip)
	ssh_client=paramiko.SSHClient()
	ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
	#ssh_client.set_missing_
	ssh_client.connect(hostname=ip.strip(),username=username,password=password,look_for_keys=False)
	print("scuuessfully connect to ",ip.strip())  

	command=ssh_client.invoke_shell()

	command.send("screen-length 0 temporary \n")   

	command.send("sys\n")
	command.send(loop_ip.strip()+'\n')
	command.send('retrun\n')
	command.send('quit\n')
	command.send('save\n')
	command.send('y\n')


	time.sleep(3)
	#command.send('display cur interface LoopBack 0\n') 
	command.send('display cur interface \n') 
	time.sleep(1)
	output=command.recv(65535)
	print(output.decode('ASCII'))

f1.close
f2.close
ssh_client.close	        